﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="接箍库存管理.aspx.cs" Inherits="syc.Fc.接箍库存管理" %>
<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript" language="javascript" src="/common.js"></script>
<form id="form1" runat="server">
<asp:Label ID="SqlText" runat="server" Text="" Visible="false"></asp:Label>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>"
onselected="SqlDataSource1_Selected" 
DeleteCommand=" delete from 自产接箍明细 where 单据ID=@ID;delete from 自产接箍判定单 where ID=@ID"
>
<DeleteParameters>
<asp:Parameter Name="ID" DbType="Int32" Size="4" />
</DeleteParameters>
</asp:SqlDataSource>

<div id="wintop" class="wintop">接箍库存管理</div>
<% 
    string op = (string)this.Session["OperatorName"];
    if (op == "杨明勇")
    {%>
     <asp:Panel ID="Panel3" runat="server" CssClass="panel" Visible="false">
    <input type="button" value="入 库" class="button" onclick="parent.swin2_load('/Fc/接箍入库单录入.aspx',820,600,'yes');"/>
    <input type="button" value="出 库" class="button" onclick="parent.swin2_load('/Fc/接箍出库单录入.aspx',560,300);"/>
    <asp:Button ID="Button2" runat="server" Text="修 改" CssClass="button" UseSubmitBehavior="False"/>
    <asp:Button ID="Button3" runat="server" Text="删 除" CssClass="button"  
        UseSubmitBehavior="False" 
        OnClientClick="if(!confirm('确认要删除该条记录吗？'))return(false);" 
        onclick="Button_Delete_Click" />
</asp:Panel>
 <%  }
    else
    {%>
<asp:Panel ID="Panel1" runat="server" CssClass="panel">
    <input type="button" value="入 库" class="button" onclick="parent.swin2_load('/Fc/接箍入库单录入.aspx',820,600,'yes');"/>
    <input type="button" value="出 库" class="button" onclick="parent.swin2_load('/Fc/接箍出库单录入.aspx',560,300);"/>
    <asp:Button ID="Button_Edit" runat="server" Text="修 改" CssClass="button" UseSubmitBehavior="False"/>
    <asp:Button ID="Button_Delete" runat="server" Text="删 除" CssClass="button"  
        UseSubmitBehavior="False" 
        OnClientClick="if(!confirm('确认要删除该条记录吗？'))return(false);" 
        onclick="Button_Delete_Click" />
</asp:Panel>
<%} %>
<asp:Panel ID="Panel2" runat="server" CssClass="panel" GroupingText="记录查询">
入出库查询：<asp:DropDownList ID="RCK" runat="server" Width="100">
<asp:ListItem Value="0">全部显示</asp:ListItem>
<asp:ListItem Value="1">入库记录</asp:ListItem>
<asp:ListItem Value="2">出库记录</asp:ListItem>
</asp:DropDownList>
<span style="margin-left:28px;">
    生产分厂：</span><asp:DropDownList ID="FenChang" runat="server" Width="120">
<asp:ListItem Value="0">全部</asp:ListItem>
<asp:ListItem Value="1">一分厂</asp:ListItem>
<asp:ListItem Value="2">二分厂</asp:ListItem>
<asp:ListItem Value="3">三分厂</asp:ListItem>
<asp:ListItem Value="4">四分厂</asp:ListItem>
<asp:ListItem Value="5">五分厂</asp:ListItem>
</asp:DropDownList>
<span style="margin-left:28px;">
判定查询：</span><asp:DropDownList ID="PanDing" runat="server" Width="100">
<asp:ListItem Value="-1">全部显示</asp:ListItem>
<asp:ListItem Value="1">判定合格</asp:ListItem>
<asp:ListItem Value="0">未判定合格</asp:ListItem>
</asp:DropDownList>
<div style="font-size:6px;height:6px;line-height:6px;"></div>
日期范围：<asp:TextBox ID="Date1" runat="server" CssClass="textbox" Width="105px"></asp:TextBox><img alt="" src="/Icons/29.png" align="middle" onclick="makecalendar(document.getElementById('Date1').value, document.getElementById('Date1'));" />
至 <asp:TextBox ID="Date2" runat="server" CssClass="textbox" Width="105px"></asp:TextBox><img alt="" src="/Icons/29.png" align="middle" onclick="makecalendar(document.getElementById('Date2').value, document.getElementById('Date2'));" />

<span style="margin-left:10px;"></span>

<asp:Button ID="Button_Query" runat="server" Text="查 询" UseSubmitBehavior="false" 
        CssClass="mbutton" onclick="Button_Query_Click" />

<asp:Button ID="Button_Reset" runat="server" Text="清空条件" UseSubmitBehavior="false" 
        CssClass="mbutton" onclick="Button_Reset_Click" />
</asp:Panel>
    <asp:Panel ID="Panel4" runat="server" CssClass="panel2">
        <asp:Label ID="Message" runat="server" Text="·准备就绪" CssClass="prompt"></asp:Label>
    </asp:Panel>

<div class="gridframe">
    <div class="gridview">
    
        <table border="1" width="100%" cellspacing="0" cellpadding="0" bordercolor="#e5cfab">
              <tr>
		           <td class="grid-title"><div style="float:left;margin-top:3px;">接箍入出库记录</div><div style="float:right;">
                    <asp:DropDownList ID="PageSizeOption" runat="server" AutoPostBack="True" 
                        onselectedindexchanged="PageSizeOption_SelectedIndexChanged">
                    <asp:ListItem Value="10" Selected="True">10 项/页</asp:ListItem>
                    <asp:ListItem Value="20">20 项/页</asp:ListItem>
                    <asp:ListItem Value="30">30 项/页</asp:ListItem>
                    <asp:ListItem Value="50">50 项/页</asp:ListItem>
                    <asp:ListItem Value="100">100 项/页</asp:ListItem>
                    </asp:DropDownList></div>
	            </td>		          
		     </tr>             
	        <tr>
	            <td class="grid-back">        
                  <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                        AutoGenerateColumns="False" CssClass="grid" DataKeyNames="ID,支数合计,合格" 
                        DataSourceID="SqlDataSource1"
                        PageSize="10"
                        GridLines="None" ondatabound="GridView1_DataBound" 
                        onpageindexchanged="GridView1_PageIndexChanged" AllowSorting="True" 
                        UseAccessibleHeader="False" 
                        onselectedindexchanged="GridView1_SelectedIndexChanged">
                        <PagerSettings Visible="False" />
                        <RowStyle CssClass="grid-row-normal" />
                        <Columns>
                        
                            <asp:TemplateField HeaderText="">
                            <ItemTemplate>
                                <asp:Button ID="Button1" runat="server" CommandName="Select" Text="选择" CssClass="hide"/>
                                <img src="/Icons/online.gif" style="margin-top:2px;" alt="" />
                            </ItemTemplate>
                            <HeaderStyle CssClass="grid-header" />
                            <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="20px" />
                        </asp:TemplateField>
                        
                        <asp:TemplateField HeaderText="入出库">
                            <ItemTemplate>
                                <asp:Label ID="Label_rc" runat="server" Text='<%# Eval("入出") %>' ForeColor='<%# ((int)Eval("支数合计"))>0?System.Drawing.Color.Green:System.Drawing.Color.Red %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle CssClass="grid-header" />
                            <ItemStyle CssClass="grid" HorizontalAlign="center" Width="80px"/>
                        </asp:TemplateField>
                        
                        <asp:TemplateField HeaderText="接箍类别" >
                            <ItemTemplate>
                                <asp:Label ID="Label5" runat="server" Text='<%# Bind("类别") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle CssClass="grid-header" />
                            <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="120px" />
                        </asp:TemplateField>
                        
                        <asp:TemplateField HeaderText="总支数">
                            <ItemTemplate>
                                <asp:Label ID="Label6" runat="server" Text='<%# Eval("支数合计") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle CssClass="grid-header" />
                            <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="80px" />
                        </asp:TemplateField>
                        
                        <asp:TemplateField HeaderText="总重(kg)">
                            <ItemTemplate>
                                <asp:Label ID="Label7" runat="server" Text='<%# Eval("重量合计") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle CssClass="grid-header" />
                            <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="80px" />
                        </asp:TemplateField>
                        
                        <asp:TemplateField HeaderText="日期" SortExpression="日期">
                            <ItemTemplate>
                                <asp:Label ID="Label3" runat="server" Text='<%# Bind("日期","{0:d}") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle CssClass="grid-header" />
                            <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="80px" />
                        </asp:TemplateField>  
                        
                       <asp:TemplateField HeaderText="是否合格">
                            <ItemTemplate>
                                <asp:Image ID="Image_hg" runat="server" ImageUrl='<%#  "/Images/hege_"+Eval("合格").ToString() +".png" %>' Visible='<%# (int)Eval("支数合计")>0 %>' />
                            </ItemTemplate>
                            <HeaderStyle CssClass="grid-header" />
                            <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="40px" />
                        </asp:TemplateField>                   
                                                                  
                       <asp:TemplateField HeaderText="录入员">
                            <ItemTemplate>
                                <asp:Label ID="Label_zp" runat="server" Text='<%# Eval("录入") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle CssClass="grid-header" />
                            <ItemStyle CssClass="grid" HorizontalAlign="center" Width="60px" />
                        </asp:TemplateField>
                    
                        <asp:TemplateField HeaderText="判定员">
                            <ItemTemplate>
                                <asp:Label ID="Label9" runat="server" Text='<%# Eval("判定员") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle CssClass="grid-header" />
                            <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="60px" />
                        </asp:TemplateField>                      
                                <asp:TemplateField ShowHeader="False">
                                    <ItemTemplate>
<input id="mxbu" type="button" value="明细" class="smallbutton" onclick="parent.swin2_load('/Fc/接箍入库单录入.aspx?id=<%#Eval("ID") %>',820,600,'yes');" />
                                    </ItemTemplate>
                                </asp:TemplateField>                          

                        </Columns>
                        <SelectedRowStyle CssClass="grid-row-selected" />
                      </asp:GridView>                    
                      
                      
                   
	            </td>
            </tr>
            <tr>
	            <td>   
	                <table width="100%">
	                    <tr>
	                        <td class="pagebar">
                                <asp:Button ID="Button_Pager_First" UseSubmitBehavior="false" runat="server" Text="" ToolTip="首页" 
                                    CssClass="pageturn-first-b" onclick="Pager_Click" CommandName="--" />
                                <asp:Button ID="Button_Pager_Prev" UseSubmitBehavior="false" runat="server" Text="" ToolTip="上一页" 
                                    CssClass="pageturn-prev-b" onclick="Pager_Click" CommandName="-" />
                                <input type="button" class="page-split" UseSubmitBehavior="false" disabled />第<asp:TextBox 
                                    ID="TextBox_Pager" AutoPostBack="True" runat="server" CssClass="pageturn" 
                                    ontextchanged="Pager_Click"></asp:TextBox>页<input type="button" class="page-split" disabled /><asp:Label ID="Label_Pages" UseSubmitBehavior="false" runat="server"></asp:Label><input type="button" class="page-split" disabled />
                                
                                <asp:Button ID="Button_Pager_Next" UseSubmitBehavior="false" runat="server" Text="" ToolTip="下一页" 
                                    CssClass="pageturn-next-b" onclick="Pager_Click" CommandName="+" />
                                <asp:Button ID="Button_Pager_Last" UseSubmitBehavior="false" runat="server" Text="" ToolTip="末页" 
                                    CssClass="pageturn-last-b" onclick="Pager_Click" CommandName="++" /><asp:Label ID="Label9" runat="server"></asp:Label><input type="button" class="page-split" disabled />
                            </td>
                            <td class="pagebar" align="right">
                                <asp:Label ID="Label_Total" runat="server"></asp:Label>
                            </td>
                        </tr>
                   </table>

	            </td>
            </tr>
        </table>
        

    </div>
</div>

</form>
<script>
    var notice = '<%=this.Notice %>';
    if (notice != '') {
        parent.showmsgbox(notice);
    }
    var textboxs = document.getElementsByTagName("input");
    var i;
    for (i = 0; i < textboxs.length; i++) {
        if (textboxs[i].className == "textbox") {
            //textboxs[i].onchange = function(e) { this.className = "textbox-changed"; };
            textboxs[i].onfocus = function(e) { this.select(); };
        }
        else if (textboxs[i].className == "pageturn" || textboxs[i].className == "intxt1" || textboxs[i].className == "intxt2") {
            textboxs[i].onfocus = function(e) { this.select(); };
        }
    }
    var rows = document.getElementsByTagName("tr");
    for (i = 0; i < rows.length; i++) {

        if (rows[i].className == "grid-row-normal") {
            rows[i].onmouseover = function() { this.className = "grid-row-bright"; };
            rows[i].onmouseout = function() { this.className = "grid-row-normal"; };
            rows[i].onclick = selectRow;
        }
    }
    document.onkeydown = function(e) {
        if (!e) e = window.event;
        var tag = e.srcElement;
        if (!tag) tag = e.target;
        if (tag.tagName == "INPUT" && tag.className == "textbox" || tag.tagName == "SELECT") {
            if (e.keyCode == 13) e.keyCode = 9;
        }
    }

    var rows = document.getElementById("GridView1").rows;
    var sum1 = 0, sum2 = 0, sum3 = 0, sum4 = 0;
    var n1, n2;
    for (i = 1; i < rows.length; i++) {
        n1 = Number(rows[i].cells[3].innerText);
        n2 = Number(rows[i].cells[4].innerText)
        if (n1 >= 0) {
            sum1 += n1;
            sum3 += n2;
        }
        else {
            sum2 += n1;
            sum4 += n2;
        }
    }
    var total = document.getElementById("Label_Total");
    total.innerHTML += "　　本页小计：" + (rows.length - 1) + " 项 入库：" + sum1 + "支 重量：" + fixFloatZ(sum3, 1) + " kg 出库：" + (-sum2) + "支 重量：" + fixFloatZ(-sum4, 1) + " kg ";

</script>
</body>
</html>
